<?php

class AbstractPlugin
{

    protected function __construct() {}

    static function getInstance()
    {
        static $instance = null;
        if (is_null($instance)) {
            $instance = new self();
        }

        return $instance;
    }

    final public function AcceptEvent(Event $event)
    {
        if (! ($event instanceof Event)) {
            throw new ArchException();
        }
        $method = 'On'.$event->name;
        if (method_exists($this, $method)) {
            $result = $this->{$method}($event);
            if ($event->cancellable) {
                return $result;
            }
        }
    }

    protected function OnInit(Event $event)
    {
    }

    protected function OnShutdown(Event $event)
    {
    }
}

?>